import * as fs from 'fs'
import * as crypto  from 'crypto'

export function getImageMD5Sync(filePath: string) {
    const fileBuffer = fs.readFileSync(filePath);
    const hash = crypto.createHash('md5');
    hash.update(fileBuffer);
    return hash.digest('hex');
}
export function removeJsonComments(jsonString: string) {
    // 删除 // 开头的整行注释
    // 以及行尾的 // 注释
    return jsonString
        .replace(/\s*\/\/.*$/gm, '')  // 行尾注释
        .replace(/^\s*\/\/.*$/gm, ''); // 整行注释
}